Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .d.tss and make them visible in tests #95

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ module.exports = {
extends: ['@metamask/eslint-config-typescript'],
},

{
files: ['*.d.ts'],
parserOptions: {
sourceType: 'script',
},
},

{
files: ['*.js'],
parserOptions: {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"build:clean": "rimraf dist && yarn build",
"build": "tsc --project ."
"build": "tsc --project tsconfig.build.json"
},
"devDependencies": {
"@lavamoat/allow-scripts": "^1.0.5",
Expand Down
11 changes: 11 additions & 0 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"declaration": true,
"declarationDir": "dist",
"rootDir": "src",
"outDir": "dist"
},
"include": ["./src/**/*.ts"],
"exclude": ["./src/**/*.test.ts"]
}
11 changes: 5 additions & 6 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
{
"compilerOptions": {
"declaration": true,
"baseUrl": ".",
"esModuleInterop": true,
"inlineSources": true,
"lib": ["ES2020"],
"module": "CommonJS",
"moduleResolution": "Node",
"outDir": "dist",
"rootDir": "src",
"paths": {
"*": ["./types/*"]
Copy link
Member

Choose a reason for hiding this comment

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

These docs on path mapping seem to imply this would overwrite the compiler's default behavior for looking up type information. So I was a bit concerned that this wouldn't look in node_modules anymore, or follow the standard Node.js module resolution. But it looks like it still does that if it can't find types here. At least locally that's what I'm seeing.

},
"sourceMap": true,
"strict": true,
"target": "ES2017"
},
"exclude": ["./src/**/*.test.ts"],
"include": ["./src/**/*.ts"]
}
}