diff --git a/example.ts b/example.ts deleted file mode 100644 index a201bd7..0000000 --- a/example.ts +++ /dev/null @@ -1 +0,0 @@ -console.log('Some .ts code reproducing a bug'); diff --git a/package.json b/package.json index 4d56496..5131ce0 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,6 @@ { "dependencies": { + "@mailchimp/mailchimp_marketing": "latest", "ts-node": "latest", "typescript": "latest" } diff --git a/run.sh b/run.sh index d553b44..7407146 100644 --- a/run.sh +++ b/run.sh @@ -6,8 +6,9 @@ n lts # Install package.json dependencies yarn -# Run ts-node -yarn ts-node ./example.ts +# Run +yarn tsc --traceResolution +yarn ts-node ./src/index.ts echo "Process exited with code: $?" echo diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..45708d2 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,8 @@ +import {foo} from '@mailchimp/mailchimp_marketing'; + +try { + console.log(foo.indexOf('f')); +} catch(e) { + // we expect to get a runtime error because mailchimp_marketing does not actually export `foo` + // The important thing is that typechecking succeeds +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..786b86a --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,10 @@ +{ + "compilerOptions": { + "target": "ESNext", + "module": "commonjs", + "moduleResolution": "node", + "typeRoots": ["./types", "./node_modules/@types"], + "types": ["@mailchimp/mailchimp_marketing"] + }, + "include": ["src"] +} \ No newline at end of file diff --git a/types/@mailchimp/mailchimp_marketing/index.d.ts b/types/@mailchimp/mailchimp_marketing/index.d.ts new file mode 100644 index 0000000..ef97817 --- /dev/null +++ b/types/@mailchimp/mailchimp_marketing/index.d.ts @@ -0,0 +1,3 @@ +declare module "@mailchimp/mailchimp_marketing" { + export const foo: 'bar'; +} \ No newline at end of file