Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ dist
lib
es
coverage
types

website/translated_docs
website/build/
Expand Down
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,26 +26,27 @@
"main": "lib/redux.js",
"unpkg": "dist/redux.js",
"module": "es/redux.js",
"typings": "./index.d.ts",
"types": "types/index.d.ts",
"files": [
"dist",
"lib",
"es",
"src",
"index.d.ts"
"types"
],
"scripts": {
"clean": "rimraf lib dist es coverage",
"clean": "rimraf lib dist es coverage types",
"format": "prettier --write \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
"format:check": "prettier --list-different \"{src,test}/**/*.{js,ts}\" index.d.ts \"**/*.md\"",
"lint": "eslint --ext js,ts src test",
"pretest": "npm run build",
"test": "jest",
"test:watch": "npm test -- --watch",
"test:cov": "npm test -- --coverage",
"build": "rollup -c",
"build": "npm run build-types && rollup -c",
"prepare": "npm run clean && npm run check-types && npm run format:check && npm run lint && npm test",
"check-types": "tsc",
"build-types": "tsc --emitDeclarationOnly",
"check-types": "tsc --noEmit",
"examples:lint": "eslint --ext js,ts examples",
"examples:test": "cross-env CI=true babel-node examples/testAll.js"
},
Expand Down
2 changes: 1 addition & 1 deletion test/typescript/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"strict": true,
"baseUrl": "../..",
"paths": {
"redux": ["index.d.ts"]
"redux": ["types/index.d.ts"]
}
}
}
16 changes: 9 additions & 7 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@
// "allowJs": true /* Allow javascript files to be compiled. */,
// "checkJs": true, /* Report errors in .js files. */
"jsx": "react" /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */,
// "declaration": true /* Generates corresponding '.d.ts' file. */,
// "declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
"declaration": true /* Generates corresponding '.d.ts' file. */,
"declarationMap": true /* Generates a sourcemap for each corresponding '.d.ts' file. */,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

question: is this useful? It pops a sourcemap into the types/ directory but I'm not sure anyone would use it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does VS Code pick this up when I hit Go To Definition? That's what I would assume to use it for.

I'm inclined to thing they're not useful, though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

another question: Do we still need the .d.ts files? Can't we just distribute src/ now?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the individual ones, just the main index.d.ts. Rewinding back a bit, I would expect that to be in the package root like it is now.

We already put the src into the package verbatim.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so is there any reason we can't do "typings": "src/index.ts"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not the individual ones, just the main index.d.ts. Rewinding back a bit, I would expect that to be in the package root like it is now.

I tried to do this, it isn't possible in an automatic way, because typescript automatically ignores the directory we tell it to pop its results into, probably to avoid infinite loops.

We can just manually cp types/index.d.ts . but it seems unnecessary to me. I haven't seen any other examples out there that keep any autogenerated files in the repo

Also, I checked, and no one is using "types": "index.ts" so I'm going to assume it's a bad idea

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, we don't need definitions because we are fully TS'ed now.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@timdorr "Go to Definition" doesn't work like that with sourcemaps.

@cellog "types": "index.ts" is definitely a bad idea, as the types are supposed to point to a .d.ts file. All TS files should be gone when you publish to npm.

@timdorr do you mean we don't need manually-typed definitions? Correct. Still need auto-generated ones though.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We publish src now. We want that in the package so the source is always available to read through. It's small and I consider it an important feature of Redux.

Whether we use that for our types or not, it's going to stay in the package.

"declarationDir": "./types" /* Output directory for generated declaration files. */,
// "emitDeclarationOnly": true /* Only emit ‘.d.ts’ declaration files. */,
"sourceMap": true /* Generates corresponding '.map' file. */,
// "outFile": "./", /* Concatenate and emit output to single file. */
// "outDir": "." /* Redirect output structure to the directory. */,
// "outDir": "./types" /* Redirect output structure to the directory. */,
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
"removeComments": false /* Do not emit comments to output. */,
"noEmit": true /* Do not emit outputs. */,
// "noEmit": true /* Do not emit outputs. */,
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */,
Expand All @@ -42,9 +44,9 @@
/* Module Resolution Options */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"baseUrl": "./" /* Base directory to resolve non-absolute module names. */,
"paths": {
"*": ["*", "types/*"]
} /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */,
// "paths": {
// "*": ["*", "types/*"]
// } /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */,
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
Expand Down