Skip to content

Commit

Permalink
TODO: Failing test that should pass
Browse files Browse the repository at this point in the history
  • Loading branch information
SBoudrias committed May 24, 2023
1 parent ebf9f85 commit fb3df11
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 13 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@ jobs:
env:
CI: true
FORCE_COLOR: 1
- name: Compile TS code
run: yarn lerna run tsc

# TS must run before we check dependencies since otherwise our exports map points to nothing.
- name: Typescript
Expand Down
34 changes: 27 additions & 7 deletions packages/canary/package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
{
"name": "@inquirer/canary",
"type": "module",
"version": "0.0.27-alpha.0",
"description": "Inquirer input text prompt",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "./dist/cjs/index.js",
"typings": "./dist/cjs/types/index.d.cts",
"files": [
"dist/"
"dist/**/*"
],
"repository": "SBoudrias/Inquirer.js",
"repository": {
"type": "git",
"url": "https://github.com/SBoudrias/Inquirer.js.git"
},
"keywords": [
"answer",
"answers",
"ask",
"base",
"cli",
"cli",
"command",
"command-line",
"confirm",
Expand Down Expand Up @@ -66,9 +67,28 @@
"lodash": "^4.17.21"
},
"scripts": {
"tsc": "tsc"
"tsc": "yarn run clean && yarn run tsc:esm && yarn run tsc:cjs",
"clean": "rm -rf dist",
"tsc:esm": "tsc -p ./tsconfig.json",
"tsc:cjs": "tsc -p ./tsconfig.cjs.json && yarn run fix-ext",
"fix-ext": "node --no-warnings=ExperimentalWarning --loader=ts-node/esm ../../tools/fix-ext.mts"
},
"publishConfig": {
"access": "public"
},
"engines": {
"node": ">=14.18.0"
},
"exports": {
".": {
"import": {
"types": "./dist/esm/types/index.d.mts",
"default": "./dist/esm/index.mjs"
},
"require": {
"types": "./dist/cjs/types/index.d.cts",
"default": "./dist/cjs/index.js"
}
}
}
}
2 changes: 1 addition & 1 deletion packages/canary/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function createPromptModule() {
select,
};

type GetPrompt<U extends keyof typeof promptStore> = typeof promptStore[U];
type GetPrompt<U extends keyof typeof promptStore> = (typeof promptStore)[U];
type GetAnswerType<U extends keyof typeof promptStore> = GetPrompt<U> extends Prompt<
infer Answer,
any
Expand Down
11 changes: 11 additions & 0 deletions packages/canary/tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "./tsconfig.json",
"include": ["./src"],
"compilerOptions": {
"lib": ["ES6"],
"target": "es6",
"moduleResolution": "node",
"outDir": "dist/cjs",
"declarationDir": "dist/cjs/types"
}
}
10 changes: 7 additions & 3 deletions packages/canary/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{
"extends": "../../tsconfig.json",
"include": ["./src"],
"compilerOptions": {
"outDir": "./dist",
},
"include": ["./src"]
"lib": ["ESNext"],
"target": "es2022",
"moduleResolution": "nodenext",
"outDir": "dist/esm",
"declarationDir": "dist/esm/types"
}
}
22 changes: 22 additions & 0 deletions packages/canary/types.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,26 @@ describe('Library types work properly', () => {
]);
}).toBeInstanceOf(Function);
});

it('register prompt', () => {
expect(() => {
inquirer.prompt([
{
/* @ts-expect-error: this prompt doesn't exist */
type: 'unknown-prompt',
name: 'ask_last_name',
message: 'Are you willing to share your last name',
},
]);

inquirer.registerPrompt('unknown-prompt', {} as any);
inquirer.prompt([
{
type: 'unknown-prompt',
name: 'ask_last_name',
message: 'Are you willing to share your last name',
},
]);
}).toBeInstanceOf(Function);
});
});

0 comments on commit fb3df11

Please sign in to comment.