Khan / aphrodite

Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation
5.35k stars 188 forks source link

About the type definition issue on StyleDeclarationMap #388

Open Shad02w opened 4 years ago

Shad02w commented 4 years ago

TypeScript Version: 3.7.5 Aphrodite Version: 2.4.0 When I using StyleSheet create function

const style = StyleSheet.create({
    container: {
    }
})

I found out that VS Code is not able to give me any autocomplete suggestion on those CSS properties, since they think StyleDeclarationMap is a type of 'any'

Snipaste_2020-02-05_18-37-10 but it is not Snipaste_2020-02-05_18-35-36

I have changed typescript version and modified my tsconfig file, but nothing make it work.

I wonder how can I fixed this issue?

Shad02w commented 4 years ago

I just figured it out myself, all you need to do is change compile target in tsconfig.json from "es5" to "es6", since typescript may not support Map object when targeting "es5".

For reference :https://github.com/Microsoft/TypeScript/issues/6842

ranzolinrafa commented 3 years ago

I'm having same problem, already changed my target to ES6 in tsconfig.json but the auto complete stills dont work

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "declaration": true,
    "module": "ESNext",
    "target": "ES6",
    "lib": ["es6", "dom", "es2016", "es2017"],
    "sourceMap": true,
    "jsx": "react",
    "moduleResolution": "node",
    "allowSyntheticDefaultImports": true,
    "esModuleInterop": true,
    "rootDir": "./src",
    "outDir": "./dist",
    "composite": true,
    "noEmit": false
  }
}

I just figured it out myself, all you need to do is change compile target in tsconfig.json from "es5" to "es6", since typescript may not support Map object when targeting "es5".

For reference :microsoft/TypeScript#6842