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

feat(ts): auto generate tsconfig.json #4776

Merged
merged 24 commits into from Jan 23, 2019

Conversation

Projects
None yet
5 participants
@kevinmarrec
Copy link
Member

commented Jan 16, 2019

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

This PR implements the autogeneration of a default tsconfig.json (if no one exists):

{
  "extends": "@nuxt/typescript",
  "compilerOptions": {
    "baseUrl": "."
  }
}

It extends a base tsconfig.json defined in a new @nuxt/typescript package, shipped by nuxt-ts distribution.

baseUrl is mandatory cause of a relativePaths thing.

Todo

  • Define a default/base tsconfig.json which all projects can now extend from
  • Ship @types/node dependency and all TypeScript dependencies under a new @nuxt/typescript package
  • Reference @types/node & @nuxt/vue-app in base tsconfig.json
  • Update examples and fixtures tsconfig.json files
  • Find a way to make base tsconfig.json reference edge versions of types when publishing edge version
  • Looks for the right tsconfig.json path when using nuxt-ts path/to/project
  • Implement a prompt which ask you confirmation for generating the tsconfig.json if it doesn't exist
  • Add a tests which check the file creation/content and that ts-node is registered

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly. (PR: #)
  • I have added tests to cover my changes (if not applicable, please state why)
  • All new and existing tests are passing.
@codecov-io

This comment has been minimized.

Copy link

commented Jan 16, 2019

Codecov Report

Merging #4776 into dev will decrease coverage by 0.3%.
The diff coverage is 55%.

Impacted file tree graph

@@            Coverage Diff             @@
##              dev    #4776      +/-   ##
==========================================
- Coverage   91.53%   91.22%   -0.31%     
==========================================
  Files          70       73       +3     
  Lines        2339     2359      +20     
  Branches      580      582       +2     
==========================================
+ Hits         2141     2152      +11     
- Misses        180      189       +9     
  Partials       18       18
Impacted Files Coverage Δ
packages/typescript/src/index.js 50% <50%> (ø)
packages/typescript/src/ts-node.js 50% <50%> (ø)
packages/typescript/src/config-generation.js 57.14% <57.14%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f8c86f2...0976aa2. Read the comment docs.

@kevinmarrec kevinmarrec added the WIP label Jan 17, 2019

@kevinmarrec kevinmarrec changed the title WIP: feat(ts): Autogenerate tsconfig.json feat(ts): Autogenerate tsconfig.json Jan 17, 2019

@kevinmarrec kevinmarrec requested a review from pi0 Jan 17, 2019

@Atinux

This comment has been minimized.

Copy link
Member

commented Jan 17, 2019

Great PR @kevinmarrec :)

Using nuxt-ts will always create the tsconfig.json where you're running the command, so it may cause unexpected behaviors like yarn nuxt-ts test/fixtures/typescript or yarn nuxt-ts examples/typescript creating a tsconfig.json in root folder.

About this, I guess we could add a prompt if no tsconfig.json is found to create one, WDTY?

@kevinmarrec

This comment has been minimized.

Copy link
Member Author

commented Jan 17, 2019

Thanks @Atinux ! Seems to be a good solution, which library should be used for the prompt ? Have you any link to some code already using a prompt within Nuxt core (similar case where prompt is needed maybe ?) ?

@kevinmarrec

This comment has been minimized.

Copy link
Member Author

commented Jan 17, 2019

And how can the prompt could be skipped with a true value in tests ?
I think we can have a simple test which check the creation and the content of the tsconfig.json, but I don't know yet how to achieve that

Show resolved Hide resolved distributions/nuxt-ts/package.js Outdated

@kevinmarrec kevinmarrec removed the WIP label Jan 19, 2019

@kevinmarrec kevinmarrec requested review from pi0 and Atinux Jan 19, 2019

@kevinmarrec

This comment has been minimized.

Copy link
Member Author

commented Jan 19, 2019

This PR is ready for final review, and please check Notes about future improvement section of the PR description.

Show resolved Hide resolved distributions/nuxt-ts/src/index.js Outdated
Show resolved Hide resolved distributions/nuxt-ts/src/index.js Outdated
@pi0
Copy link
Member

left a comment

Overall LGTM. Left minor comments.

@kevinmarrec

This comment has been minimized.

Copy link
Member Author

commented Jan 20, 2019

My last commit will make the extended tsconfig.json local path openable from terminals which support it when the autogeneration is done :) (I made it work for either nuxt-ts or nuxt-ts-edge)

Like this (VSCode supports Ctrl + Click to follow link in integrated terminal):
screenshot_22

husayt and others added some commits Jan 21, 2019

add resolveJsonModule in default config
Co-Authored-By: kevinmarrec <kevin@marrec.io>

@kevinmarrec kevinmarrec added the WIP label Jan 21, 2019

@kevinmarrec

This comment has been minimized.

Copy link
Member Author

commented Jan 21, 2019

New version proposal (WIP - not polished/finished yet)
dev...kevinmarrec:nuxt-typescript-package

EDIT : I merged it in this PR (5cb2419) and removed my other branch

@kevinmarrec kevinmarrec force-pushed the kevinmarrec:autogenerate-tsconfig branch from 103aec7 to 5cb2419 Jan 21, 2019

@kevinmarrec kevinmarrec removed the WIP label Jan 21, 2019

@pi0 pi0 changed the title feat(ts): Autogenerate tsconfig.json feat(ts): auto generate tsconfig.json Jan 21, 2019

pi0 and others added some commits Jan 22, 2019

@husayt

husayt approved these changes Jan 22, 2019

Copy link
Collaborator

left a comment

This is cool. Thanks @kevinmarrec

@Atinux Atinux merged commit 2a1ee96 into nuxt:dev Jan 23, 2019

11 checks passed

Semantic Pull Request ready to be squashed
Details
[ci.azure] nuxt.js #20190122.18 succeeded
Details
ci/circleci: audit Your tests passed on CircleCI!
Details
ci/circleci: build Your tests passed on CircleCI!
Details
ci/circleci: lint Your tests passed on CircleCI!
Details
ci/circleci: lint-app Your tests passed on CircleCI!
Details
ci/circleci: setup Your tests passed on CircleCI!
Details
ci/circleci: test-e2e Your tests passed on CircleCI!
Details
ci/circleci: test-types Your tests passed on CircleCI!
Details
ci/circleci: test-unit Your tests passed on CircleCI!
Details
security/snyk - package.json (Atinux) No new issues
Details

@kevinmarrec kevinmarrec deleted the kevinmarrec:autogenerate-tsconfig branch Jan 24, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.