Typescript: Erroneous specifiers in declaration files.

Created on 8 Aug 2018  路  2Comments  路  Source: microsoft/TypeScript


TypeScript Version: 3.0.1


Search Terms: import, eac

Code

// A *self-contained* demonstration of the problem follows...
// Test this by running `tsc` on the command-line, rather than through another build tool such as Gulp, Webpack, etc.
import styled from "react-emotion"

const Form = styled('div')({ color: "red" })

export default Form

Expected behavior:
When run with --declaration, the output I expected was:

import * as React from "react";
export declare const Form: import("create-emotion-styled/types/react").StyledOtherComponent<{}, React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any>;
export default Form;

Actual behavior:
When run with --declaration, the generated .d.ts file contains:

/// <reference path="../../node_modules/create-emotion/types/index.d.ts" />
/// <reference types="react" />
export declare const Form: import("create-emotion-styled/types/react").StyledOtherComponent<{}, import("eac").DetailedHTMLProps<import("eac").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, any>;
export default Form;

What's really strange is import("eac"). Where in the world is this coming from? 馃

Playground Link:
I can't add a playground link because it depends on import.

Related Issues: https://github.com/emotion-js/emotion/issues/788

Bug

Most helpful comment

If I had to guess: "eac" is the middle 3 characters of "react" and we're trimming the leading and trailing characters expecting them to be quotations (ambient modules are supposed to always be quoted), but they're not. 馃槃

All 2 comments

If I had to guess: "eac" is the middle 3 characters of "react" and we're trimming the leading and trailing characters expecting them to be quotations (ambient modules are supposed to always be quoted), but they're not. 馃槃

awesome!

Was this page helpful?
0 / 5 - 0 ratings